var app = sm("do_App");
var page = sm("do_Page");
var cacher = sm("do_DataCache");
var common = require("common");
var mallUrl = require("url/mall");
var qqHttp = require("helper/http");

page.on("productContent",function(productId){
	var labelContent = ui("labelContent");
	var layoutImgs = ui("layoutImgs");
	if(productId==cacher.loadData("cacheProdeuctId")&&cacher.hasData("cacheProdeuctData")){
		var data = cacher.loadData("cacheProdeuctData");
		labelContent.text = data.resumeText;
		var imgs = data.imgItems;
		var len = imgs.length>9?9:imgs.len;
		for(var i=0;i<len;i++){
			ui("img"+i).source = imgs[i].source;
			ui("img"+i).visible = true;
		}
		return;
	}
	cacher.saveData("cacheProdeuctId",productId);
	qqHttp.post(mallUrl.url.product.resume, {id:productId}, function(data){
		cacher.saveData("cacheProdeuctData",data);
		//详情图片
		labelContent.text = data.resumeText;
		var imgs = data.imgItems;
		var length = imgs.length>9?9:imgs.length;
		for(var i=0;i<length;i++){
			ui("img"+i).source = imgs[i].source;
			ui("img"+i).visible = true;
		}
	});
})
